const MYSQL = require("../../sql/mysql");
// MYSQL数据库配置信息
const MYSQLConfig = require("../../sql/database");
let sqlName = MYSQLConfig.datasheetName.roles;
/**
 * 修改角色信息
 * @param {object} params
 * @param {string} params.id 修改的角色id
 * @param {string} params.name 新的角色名称
 * @param {string} params.scope 新的权限标识
 * @param {string} params.state 新的state
 * @returns {Promise<{code:string,msg:string}>}
 */
module.exports = async (params = {}) => {
  let { id, name, scope, comment, state } = params;
  if (!id) {
    throw {
      code: 500,
      msg: "id不能为空",
    };
  }
  let updateData = {};
  if (name) {
    updateData.name = name;
  }
  if (scope) {
    updateData.scope = scope;
  }
  if (comment) {
    updateData.comment = comment;
  }
  return {
    code: 0,
    msg: "操作成功",
    updateData,
  };
};
